home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.util.Debug;
- import com.extensibility.util.StringUtilities;
- import java.util.Vector;
-
- public class Comment implements Cloneable {
- protected static final char KIND_START = '#';
- protected static final char KIND_END = ':';
- public static final String USAGE = "USAGE";
- public static final String AUTHOR_OBSOLETE = "AUTHOR";
- public static final String CHANGES = "CHANGES";
- public static final String INTRO = "INTRO";
- public static final String UNKIND = "";
- public static final String ALL = null;
- private static Vector KIND_ORDER = new Vector();
- String comment;
- String kind;
-
- public Comment(String var1) {
- KIND_ORDER.addElement("");
- KIND_ORDER.addElement("USAGE");
- KIND_ORDER.addElement("CHANGES");
- KIND_ORDER.addElement("INTRO");
- this.comment = var1;
- if (var1.length() > 0 && var1.charAt(0) == '#') {
- int var2 = var1.indexOf(58);
- if (var2 > 0) {
- this.kind = var1.substring(1, var2);
- this.comment = var1.substring(var2 + 1, var1.length());
- this.removeObsoleteKind();
- }
- }
-
- }
-
- public Comment(String var1, String var2) {
- KIND_ORDER.addElement("");
- KIND_ORDER.addElement("USAGE");
- KIND_ORDER.addElement("CHANGES");
- KIND_ORDER.addElement("INTRO");
- this.kind = var1;
- this.comment = var2;
- this.removeObsoleteKind();
- }
-
- private void removeObsoleteKind() {
- if (this.kind != null) {
- if (this.kind.equals("AUTHOR") || this.kind.length() == 0) {
- this.kind = null;
- }
-
- }
- }
-
- public Object clone() {
- Comment var1 = null;
-
- try {
- var1 = (Comment)super.clone();
- } catch (CloneNotSupportedException var3) {
- Debug.assert(false, "Problem cloning Comment.");
- }
-
- return var1;
- }
-
- public int compareKindTo(Comment var1) {
- return this.getKindIndex() - var1.getKindIndex();
- }
-
- public void setComment(String var1) {
- this.comment = var1;
- }
-
- public String getComment() {
- return this.comment;
- }
-
- public String getComment(boolean var1) {
- if (!var1) {
- return this.getComment();
- } else {
- String var2 = this.comment;
- var2 = StringUtilities.replace(var2, "&", "&");
- var2 = StringUtilities.replace(var2, "<", "<");
- var2 = StringUtilities.replace(var2, ">", ">");
- return var2;
- }
- }
-
- public String toString() {
- return this.comment;
- }
-
- public String getSource() {
- return this.kind != null ? String.valueOf(String.valueOf(String.valueOf(String.valueOf(String.valueOf("<!--#").concat(String.valueOf(this.kind))).concat(String.valueOf(':'))).concat(String.valueOf(StringUtilities.replace(this.comment, "--", "- -")))).concat(String.valueOf("-->"))).concat(String.valueOf(BaseDeclaration.LINE_SEPARATOR)) : String.valueOf(String.valueOf(String.valueOf("<!--").concat(String.valueOf(StringUtilities.replace(this.comment, "--", "- -")))).concat(String.valueOf("-->"))).concat(String.valueOf(BaseDeclaration.LINE_SEPARATOR));
- }
-
- private int getKindIndex() {
- int var1;
- for(var1 = 0; var1 < KIND_ORDER.size(); ++var1) {
- if (((String)KIND_ORDER.elementAt(var1)).equals(this.getKind())) {
- return var1;
- }
- }
-
- return var1;
- }
-
- public String getKind() {
- return this.kind == null ? "" : this.kind;
- }
- }
-